// @include "../../../scripts/spket.js"

(function() {
	testPage = {
		name: function() {	
			return "Page Test";
		},
		setUp: function() {
				clear();
				init();
		},
		tearDown: function() {
			clear();
		},
		testIndex: function() {
			var users = getUsers();
	
			var ret = page.index();
	
			Assert.assertTrue(ret.indexOf(users[0].name) >= 0);
			Assert.assertTrue(ret.indexOf(users[0].desc) >= 0);
			Assert.assertTrue(ret.indexOf(users[1].name) >= 0);
			Assert.assertTrue(ret.indexOf(users[1].desc) >= 0);
		}
	};

	function clear() {
		panda.db.get("users").drop();
	}

	function init() {
		var users = panda.db.get("users");
		users.ensureIndex({ name: 1 });
		users.insert({ name: "user1", desc: "desc1" });
		users.insert({ name: "user2", desc: "desc2" });
	}

	function getUsers() {
		var users = panda.db.get("users");
		return users.list().$sort({ name: 1 });
	}
}());
